package org.example.jedis.pipeline;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.Pipeline;

/**
 * @author kylin
 * @date 2020/4/18
 * @desc pipeline 批量写操作
 * <p>
 * @see PipelineGet 测试读
 */
public class PipelineSet {
    public static void main(String[] args) {
        Jedis jedis = new Jedis("192.168.165.7", 6379);
        Pipeline pipelined = jedis.pipelined();
        long t1 = System.currentTimeMillis();
        for (int i = 0; i < 1000000; i++) {
            pipelined.set("batch" + i, "" + i);
        }
        pipelined.syncAndReturnAll();
        long t2 = System.currentTimeMillis();
        System.out.println("耗时：" + (t2 - t1) + "ms");
        // 耗时：1964ms 垃圾虚拟机测试
    }
}
